package cn.ld.module.system.dal.mapper.tenant;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.tenant.vo.packages.TenantPackagePageInVO;
import cn.ld.module.system.dal.entity.tenant.TenantPackageEntity;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 租户套餐 Mapper
 *
 * @author 蓝盾
 */
@Mapper
public interface TenantPackageMapper extends BaseMapperX<TenantPackageEntity> {

    default PageResult<TenantPackageEntity> selectPage(TenantPackagePageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<TenantPackageEntity>()
                .likeIfPresent(TenantPackageEntity::getName, inVO.getName())
                .eqIfPresent(TenantPackageEntity::getStatus, inVO.getStatus())
                .likeIfPresent(TenantPackageEntity::getRemark, inVO.getRemark())
                .betweenIfPresent(TenantPackageEntity::getCreateTime, inVO.getCreateTime())
                .orderByDesc(TenantPackageEntity::getId));
    }

    default List<TenantPackageEntity> selectListByStatus(Integer status) {
        return selectList(TenantPackageEntity::getStatus, status);
    }

    default TenantPackageEntity selectByName(String name) {
        return selectOne(TenantPackageEntity::getName, name);
    }
}
